﻿using Engine;
using Game;
using GameEntitySystem;

public class HDHX : SubsystemBlockBehavior, IUpdateable
{
    public SubsystemTime m_subsystemTime;

    public SubsystemGameInfo m_subsystemGameInfo;

    public Game.Random m_random = new Game.Random();

    public SubsystemAudio m_subsystemAudio;

    public ComponentPlayer m_componentPlayer;

    public override int[] HandledBlocks => new int[1]
    {
            582
    };

    public UpdateOrder UpdateOrder => UpdateOrder.Default;

    //交互方法，当行为方块被玩家点击交互时执行
    public override bool OnInteract(TerrainRaycastResult raycastResult, ComponentMiner componentMiner)
    {
        ComponentPlayer componentPlayec = componentMiner.ComponentPlayer;
        CellFace cellFace = raycastResult.CellFace;
        Vector3 position = new Vector3(cellFace.X, cellFace.Y, cellFace.Z) + new Vector3(0.5f);

        int activeBlockValue = componentMiner.ActiveBlockValue;
        int num = Terrain.ExtractContents(activeBlockValue);
        if (num == 581)
        {
            componentMiner.RemoveActiveTool(1);
            Entity entity = DatabaseManager.CreateEntity(Project, "混沌鲸", throwIfNotFound: true);
            ComponentBody componentBody = entity.FindComponent<ComponentBody>(throwOnError: true);
            componentBody.Position = position + m_random.Vector3(0.5f);
            entity.FindComponent<ComponentSpawn>(throwOnError: true).SpawnDuration = 10f;
            Project.AddEntity(entity);
            componentMiner.ComponentPlayer.ComponentGui.DisplayLargeMessage("Boss", "你感觉到混沌了吗？", 5f, 0f);

        }
        if (num == 583)
        {
            componentMiner.RemoveActiveTool(1);
            Entity entity = DatabaseManager.CreateEntity(Project, "暮色", throwIfNotFound: true);
            ComponentBody componentBody = entity.FindComponent<ComponentBody>(throwOnError: true);
            componentBody.Position = position + m_random.Vector3(0.5f);
            entity.FindComponent<ComponentSpawn>(throwOnError: true).SpawnDuration = 10f;
            Project.AddEntity(entity);
            componentMiner.ComponentPlayer.ComponentGui.DisplayLargeMessage("暮色", "？？？", 5f, 0f);
        }
        if (num == 584)
        {
            componentMiner.RemoveActiveTool(1);
            Entity entity = DatabaseManager.CreateEntity(Project, "暮色", throwIfNotFound: true);
            ComponentBody componentBody = entity.FindComponent<ComponentBody>(throwOnError: true);
            componentBody.Position = position + m_random.Vector3(0.5f);
            entity.FindComponent<ComponentSpawn>(throwOnError: true).SpawnDuration = 10f;
            Project.AddEntity(entity);
            componentMiner.ComponentPlayer.ComponentGui.DisplayLargeMessage("暮色", "你感觉到恐惧了吗？蚂蚁！", 5f, 0f);
        }
        if (num == 598)
        {
            componentMiner.RemoveActiveTool(1);
            Entity entity = DatabaseManager.CreateEntity(Project, "血鲸", throwIfNotFound: true);
            ComponentBody componentBody = entity.FindComponent<ComponentBody>(throwOnError: true);
            componentBody.Position = position + m_random.Vector3(0.5f);
            entity.FindComponent<ComponentSpawn>(throwOnError: true).SpawnDuration = 10f;
            Project.AddEntity(entity);
            componentMiner.ComponentPlayer.ComponentGui.DisplayLargeMessage("血鲸", "你感觉到混沌之神了吗？", 5f, 0f);
        }
        return false;
    }

    public void Update(float dt)
    {
    }
}
